import io from '../../lib/io'
let myMixin = {
  computed: {
    areaTeams: function () {
      var options = (this.$root.config.areaTeams || []).map(function (item) {
        return {
          value: item.areaTeamId,
          text: item.name
        }
      })
      return options
    },
    grades() {
      return this.$root.config.grades.map(function (item) {
        return {
          value: item.gradeId,
          label: item.gradeName
        }
      })
    },
    subjects() {
      return this.$root.config.subjects.map(function (item) {
        return {
          value: item.subjectId,
          label: item.subjectName
        }
      })
    }
  },
  methods: {
    loadPeriod(areaTeamId) {
      return new Promise((resolve, reject) => {
        io.post(
          io.apiAdminPeriodListForAreaTeam, {
            areaTeamId: areaTeamId
          },
          ret => {
            if (ret.success) {
              if (ret.data.length === 0) {
                this.$alert('当前没有设置期数')
              }
              resolve(ret.data)
            } else {
              this.$alert(ret.desc)
            }
          }
        )
      })
    }
  }
}
export default myMixin
